]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
search: Use a variable for tracking allocated width
authorKhalid Abu Shawarib <kas@gnome.org>
Tue, 2 Sep 2025 22:21:00 +0000 (01:21 +0300)
committerMarge Bot <marge-bot@gnome.org>
Thu, 11 Sep 2025 10:45:57 +0000 (10:45 +0000)
Instead of the x coordinates of the allocation box.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3851>

js/ui/search.js

index 8ac92888a69cdbd080ff4af41902669561e87b0b..3204ea0b628c0164704284a63f4a5da18d677693 100644 (file)
@@ -401,8 +401,7 @@ const GridSearchResultsLayout = GObject.registerClass({
         const width = box.get_width();
 
         const childBox = new Clutter.ActorBox();
-        childBox.x1 = 0;
-        childBox.y1 = 0;
+        let accumulatedWidth = 0;
 
         let first = true;
         for (let child of container) {
@@ -412,20 +411,21 @@ const GridSearchResultsLayout = GObject.registerClass({
             if (first)
                 first = false;
             else
-                childBox.x1 += this._spacing;
+                accumulatedWidth += this._spacing;
 
             const [childWidth] = child.get_preferred_width(-1);
             const [childHeight] = child.get_preferred_height(-1);
 
-            if (childBox.x1 + childWidth <= width)
+            childBox.set_origin(accumulatedWidth, 0);
+            accumulatedWidth += childWidth;
+
+            if (accumulatedWidth <= width)
                 childBox.set_size(childWidth, childHeight);
             else
                 childBox.set_size(0, 0);
 
             child.allocate(childBox);
             child.can_focus = childBox.get_area() > 0;
-
-            childBox.x1 += childWidth;
         }
     }